import {ActionReducer, ActionReducerMap, MetaReducer} from '@ngrx/store';
import {AppState} from './app.states';
import * as authReducer from './auth.reducer';
import * as networkReducer from './network.reducer';

export const reducers: ActionReducerMap<AppState> = {
  authState: authReducer.reducer,
  networkState: networkReducer.reducer
};

export function logger(reducer: ActionReducer<AppState>): ActionReducer<AppState> {
  return function (state: AppState, action: any): AppState {
    console.log('state', state);
    console.log('action', action);
    return reducer(state, action);
  };
}

export const metaReducers: MetaReducer<AppState>[] = [logger];
